package server

import (
	"github.com/gorilla/websocket"
	"github.com/pion/webrtc/v3"
)

type MethodType string

const (
	Offer     MethodType = "offer"
	Answer    MethodType = "answer"
	Candidate MethodType = "candidate"
)

type JsonProtocol struct {
	Method MethodType `json:"method"`
	Offer  struct {
		Name   string                    `json:"name"`
		Rtsp   bool                      `json:"rtsp"`   // 请求rtsp流?
		Sample bool                      `json:"sample"` // sample方式
		Offer  webrtc.SessionDescription `json:"offer"`  // 请求
	} `json:"offer"`
	Answer struct {
		Code   int                        `json:"code"`   // 错误码
		MSG    string                     `json:"msg"`    // 信息
		Answer *webrtc.SessionDescription `json:"answer"` // 回复
	} `json:"answer"`
}

// WeSocketWebrtcConnection websocket conn
type WeSocketWebrtcConnection struct {
	UID  string `json:"uid"`
	Name string `json:"name"`

	engine *WebRtcEngine
	ws     *websocket.Conn
	pc     *webrtc.PeerConnection
}
